﻿Type=Class
Version=3.61
ModulesStructureVersion=1
B4J=true
@EndOfDesignText@
'Class module
Sub Class_Globals
	Private s60jz() As String
	Private sTiangan() As String
	Private sDizhi() As String
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
	s60jz=Array As String("甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午","辛未","壬申","癸酉","甲戌","乙亥","丙子","丁丑","戊寅","己卯","庚辰","辛巳","壬午","癸未","甲申","乙酉","丙戌","丁亥","戊子","己丑","庚寅","辛卯","壬辰","癸巳","甲午","乙未","丙申","丁酉","戊戌","己亥","庚子","辛丑","壬寅","癸卯","甲辰","乙巳","丙午","丁未","戊申","己酉","庚戌","辛亥","壬子","癸丑","甲寅","乙卯","丙辰","丁巳","戊午","己未","庚申","辛酉","壬戌","癸亥","癸亥")
	sTiangan=Array As String("甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬" ,"癸")
	sDizhi=Array As String("子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌","亥")
End Sub
'传入整数型数组,只支持公元后年份
public Sub date2gz(date() As Int) As String()
	Dim n,y,r As Int
	Dim sn,sy,sr As String
	Dim ret() As String
	n=date(0)
	n=n mod 60
	If n<4 Then n=n+60
	n=n-4
	sn=getsGz(n)
	Log(sn)
	ret=Array As String(sn)
	Return ret
End Sub
'idx范围0-59例0=甲子
public Sub getsGz(idx As Int) As String
	If idx>-1 And idx<60 Then
		Return s60jz(idx)
	Else
		Return "ErrIdx"
	End If
	
End Sub
'根据序号0-59获取干支字符例如0=甲子 此乃原始算法版本
'Public Sub getsGz(idx As Int) As String
'	Dim i,j As Int
'	Dim ret As String
'	i=0
'	j=0
'	For k=0 To 59
'		ret=sTiangan(i)&sDizhi(j)
'		If k=idx Then
'			Exit
'		Else
'			Log(ret)
'		End If
'		If i=9 Then
'			i=0
'		Else
'			i=i+1	
'		End If
'		If j=11 Then
'			j=0
'		Else
'			j=j+1
'		End If
'	Next
'	Return ret
'End Sub